// utils/request.js
export const request = (options) => {
	const token = uni.getStorageSync('token');
	options.header = options.header || {};
	if (token) {
		options.header['Authorization'] = `Bearer ${token}`;
	}
	return new Promise((resolve, reject) => {
		uni.request({
			...options,
			success: (res) => {
				if (res.statusCode === 200) {
					resolve(res.data);
				} else {
					reject(res);
				}
			},
			fail: (err) => {
				reject(err);
			}
		});
	});
};